package initialize

import (
	"ksirGo/global"
	"log"

	"github.com/minio/minio-go/v7"
	"github.com/minio/minio-go/v7/pkg/credentials"
)

func MinIO() *minio.Client {
	minioInfo := global.CONFIG.MinIO
	if !minioInfo.Enable {
		return nil
	}
	minioClient, err := minio.New(minioInfo.Endpoint, &minio.Options{
		Creds:  credentials.NewStaticV4(minioInfo.AccessKeyID, minioInfo.SecretAccessKey, ""),
		Secure: minioInfo.Secure,
	})
	if err != nil {
		log.Fatalln("minio初始化失败：", err)
		return nil
	} else {
		return minioClient
	}
}
